<?php
$ress=include_once './user.php';
include_once './config.php';
$data=$_POST;
//var_dump($data);
$res="";
$pata="/^[a-zA-Z\x{4e00}-\x{9fa5}]{2,3}$/u";

if ($data['username'] == '') {

    $res=array("error"=>0,"info"=>"名字为空啦");
    echo json_encode($res);
    return;

}
if(!preg_match($pata,$data['username'])){
    $res=array("error"=>2,"info"=>"名字2个到3个为合法");
    echo json_encode($res);
    return;
}

foreach ($ress as $v) {
    if ($v['usename'] == $data['username']) {
        $res=array("error"=>1,"info"=>"名字已占用啦！");
        echo json_encode($res);
        return;
    }
}

$res=array("error"=>4,"info"=>"");
echo json_encode($res);

